
<style type="text/css">
#calendar{width:960px; margin:20px auto 10px auto}
.fancy{width:450px; height:auto}
.fancy h3{height:30px; line-height:30px; border-bottom:1px solid #d3d3d3; font-size:14px}
.fancy form{padding:10px}
.fancy p{height:28px; line-height:28px; padding:4px; color:#999}
</style>


<script type="text/javascript">
$(function() {
	//var fstart;
	//var fend;
	//var selectdate;
	//var gView;
	
	
	function celClose(){
		//$('#calendar').fullCalendar('refetchEvents');
		//alert(gView.start);
		$.cookie('sel_start',null);
	}
	
	function openDialog(view,fstart)	{
		this.fstart=fstart;
		//alert(this.fstart);
		return new $(view).dialog({
	    	id:'mydialog1', 
	    	//type:'post',
	    	//url:'__URL__/edit/id/0/navTabId/{:CONTROLLER_NAME}/calendar/add?MeetingreservID=0&startdate=' + $selectdate + '&start=' + $.session.get('start'), 
	    	url:'__URL__/add/navTabId/{:CONTROLLER_NAME}/calendar', 		
	    	data:{'start':fstart},
	    	title:'新增',
	    	fresh:true,
	    	onClose:celClose
	    });
	}
	
	$('#calendar').fullCalendar({
		header: {
			left: 'prev,next today',
			center: 'title',
			right: 'month,agendaWeek,agendaDay'
		},
		events: {
			url:'__URL__/AjaxCale' ,
			type:'post',
			startParam:'start',
			endParam:'end',
			lazyFetching:true,
			data:{
				MeetingID:$('#s_MettingName').val()
			},
			error: function(){
				alert("Error");
			}
		},
		dayClick: function(date, allDay, jsEvent, view) {
			
			var ftempH=$.fullCalendar.formatDate(date,"HH");
			var ftempM=$.fullCalendar.formatDate(date,"mm");
			var tempClassName=ftempH*2;
			if(ftempM=='30'){
				tempClassName=tempClassName+1;
			}
			tempClassName = '.fc-slot'+tempClassName;
			
			//var $td = $(this).parents('table').attr('class')
			//alert($(tempClassName));
			//alert($(this).parent().parent().parent().parent().parent().parent().attr('class'));
			
			
			var fstart=$.fullCalendar.formatDate(date,"yyyy-MM-dd HH:mm");
		 	var fend=$.fullCalendar.formatDate(date,"yyyy-MM-dd HH:mm");
		 	var selectdate = $.fullCalendar.formatDate(date,"yyyy-MM-dd HH:mm");
		 	//alert(view.name);
			//$.cookie('sel_start',fstart);
			if(view.name=='month'){
				tempClassName=this;
			}
			$(tempClassName).dialog({
			    	id:'mydialog1', 
			    	//type:'post',
			    	//url:'__URL__/edit/id/0/navTabId/{:CONTROLLER_NAME}/calendar/add?MeetingreservID=0&startdate=' + $selectdate + '&start=' + $.session.get('start'), 
			    	url:'__URL__/add/navTabId/{:CONTROLLER_NAME}/calendar', 		
			    	data:{'sel_start':fstart,'id':'0'},
			    	title:'新增',
			    	//fresh:true,
			    	onClose:celClose
			});

    	},
    	eventClick: function(event, jsEvent, view) {
			//var selDate =$.fullCalendar.formatDate(date,'yyyy-MM-dd');
			var fstart=$.fullCalendar.formatDate(event.start,"HH:mm");
			var fend=$.fullCalendar.formatDate(event.end,"HH:mm");
			var selectdate = $.fullCalendar.formatDate(event.start,"yyyy-MM-dd");
			var resID=event.id;
			//$.cookie('sel_resid',resID);
			$(this).dialog({
		    	id:'mydialog', 
		    	url:'__URL__/edit/navTabId/{:CONTROLLER_NAME}/calendar' , 
		    	data:{id:resID,startdate:selectdate,start:fstart,end:fend},
		    	title:'编辑'
		    });
			/*
			$.fancybox({
				'type':'ajax',
				'href':'__URL__/edit/id/0/navTabId/{:CONTROLLER_NAME}?action=add&date='+selDate
			});
			*/
    	}
	});
	
});
</script>
		<div class="bjui-pageHeader" >
			<form id="pagerForm" data-toggle="ajaxsearch" action="__URL__/calendar"	method="post">
		
				
				<div class="bjui-searchBar">
		            
		            <label>会议室：</label>
			            <select  name="s_MettingName" id="s_MettingName" data-toggle="selectpicker">
		               	<option  value="0">请选择</option>
			         	<php>$listz=M('meeting')->where(array('status'=>1))->select();</php>
			          	<foreach name="listz" item="v">
		              	<option <if condition="$v.id EQ $_REQUEST['s_MettingName'] ">selected value="{$_REQUEST['s_MettingName']}" <else/>value="{$v.id}"</if> >
			          	{$v.name}
			          	</option>
		              	</foreach>
	           		</select>

		            <button type="submit"  class="btn-default" data-icon="search">查询</button>
					<span<php>echo display(CONTROLLER_NAME.'/add');</php>
						style="float:right;margin-right:20px;"><a
						href="__URL__/add/navTabId/{:CONTROLLER_NAME}"
						class="btn btn-green" data-toggle="dialog" data-width="600"
						data-height="600" data-id="dialog-mask" data-mask="true"
						data-icon="plus" id="btn_add">新增</a></span> 
						
						<span>
							<a class="btn btn-orange"
							href="javascript:;" onclick="$(this).navtab('reloadForm', true);"
							data-icon="undo">刷新</a>
						</span>
				</div>
			</form>
	</div>	           
 <div class="pageFormContent" data-layout-h="0">	            
				<div id='calendar' ></div>
</div>
